﻿using System;
using System.Collections.Generic;
using System.Text;

namespace dotHTML.HTML {
    /// <summary>
    /// Defines an HTML applet.
    /// </summary>
    [Serializable]
    [Obsolete("Deprecated in HTML4 - use <object> instead.")]
    public class Applet : Element {

        /// <summary>
        /// Defines the alignment of an applet.
        /// </summary>
        public enum AlignmentChoices {
            /// <summary>
            /// The item is aligned at the bottom of the content.
            /// </summary>
            Bottom,
            /// <summary>
            /// The item is aligned at the left of the content.
            /// </summary>
            Left,
            /// <summary>
            /// The item is aligned at the middle of the content.
            /// </summary>
            Middle,
            /// <summary>
            /// The item is aligned at the right of the content.
            /// </summary>
            Right,
            /// <summary>
            /// The item is aligned at the top of the content.
            /// </summary>
            Top
        }

        private AlignmentChoices? _align;
        private string _alt;
        private string _archive;
        private string _code;
        private string _codebase;
        private int? _height;
        private int? _hspace;
        private bool _mayscript;
        private string _name;
        private string _object;
        private int? _vspace;
        private int? _width;

        /// <summary>
        /// Gets or sets the alignment of this applet relative to the content
        /// around it.
        /// </summary>
        public AlignmentChoices? Align {
            get { return _align; }
            set { _align = value; }
        }

        /// <summary>
        /// Gets or sets alternate text to be displayed if the applet cannot be
        /// displayed.
        /// </summary>
        public string Alt {
            get { return _alt; }
            set { _alt = value; }
        }

        /// <summary>
        /// Gets or sets the URL of an alternative, compressed version of the
        /// code file for this applet.
        /// </summary>
        public string Archive {
            get { return _archive; }
            set { _archive = value; }
        }

        /// <summary>
        /// Gets or sets the URL of the code file for this applet.
        /// </summary>
        public string Code {
            get { return _code; }
            set { _code = value; }
        }

        /// <summary>
        /// Gets or sets the URL at which the Code attribute can be resolved,
        /// if it is a relative URL.
        /// </summary>
        public string CodeBase {
            get { return _codebase; }
            set { _codebase = value; }
        }

        /// <summary>
        /// Gets or sets the height of this applet.
        /// </summary>
        public int? Height {
            get { return _height; }
            set { _height = value; }
        }

        /// <summary>
        /// Gets or sets the amount of horizontal space on either side of the
        /// applet.
        /// </summary>
        public int? HSpace {
            get { return _hspace; }
            set { _hspace = value; }
        }

        /// <summary>
        /// Determines whether or not scripts in the document can access this
        /// applet.
        /// </summary>
        public bool MayScript {
            get { return _mayscript; }
            set { _mayscript = value; }
        }

        /// <summary>
        /// Gets or sets the name of this applet, so that it can be referenced
        /// from other scripts.
        /// </summary>
        public string Name {
            get { return _name; }
            set { _name = value; }
        }

        /// <summary>
        /// Gets or sets the URL of a serialized representation of the applet.
        /// </summary>
        public string Object {
            get { return _object; }
            set { _object = value; }
        }

        /// <summary>
        /// Gets or sets the amount of vertical space on either side of the
        /// applet.
        /// </summary>
        public int? VSpace {
            get { return _vspace; }
            set { _vspace = value; }
        }

        /// <summary>
        /// Gets or sets the width of the applet.
        /// </summary>
        public int? Width {
            get { return _width; }
            set { _width = value; }
        }

        /// <summary>
        /// Writes out the local attributes of this applet.
        /// </summary>
        /// <param name="sb">The StringBuilder to write this element's
        /// attribute data to.</param>
        protected override void WriteLocalAttributes(StringBuilder sb) {
            AttributeWriter.Write(sb, _align, "align", true);
            AttributeWriter.Write(sb, _alt, "alt");
            AttributeWriter.Write(sb, _archive, "archive");
            AttributeWriter.Write(sb, _code, "code");
            AttributeWriter.Write(sb, _codebase, "codebase");
            AttributeWriter.Write(sb, _height, "height");
            AttributeWriter.Write(sb, _hspace, "hspace");
            AttributeWriter.Write(sb, _mayscript, "mayscript");
            AttributeWriter.Write(sb, _name, "name");
            AttributeWriter.Write(sb, _object, "object");
            AttributeWriter.Write(sb, _vspace, "vspace");
            AttributeWriter.Write(sb, _width, "width");
        }
    }
}
